<?php
/**
* 微信公众平台 PHP SDK
*
* @author CuiHao <cuihao871120@gmail.com>
*/
namespace Wechat\API;

use Wechat\Core;

//获取关注者列表
class User extends Core
{
    //获取关注者列表
    public function GetList() {
        if ($token = $this->GetAccessToken()) {
            $url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={$token}";
            $json = $this->Get($url);
            if (isset($json['errcode'])) {
                return null;
            } else {
                return $json;
            }
        } else {
            return null;
        }
    }

    //获取用户基本信息
    public function UserInfo($openid) {
        if ($token = $this->GetAccessToken()) {
            $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$token}&openid={$openid}";
            $json = $this->Get($url);
            if (isset($json['errcode'])) {
                return null;
            } else {
                return $json;
            }
        } else {
            return null;
        }
    }
}